#coding:utf-8
import sae.const
"""
Django settings for blog_2 project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from os import environ
from django.conf.global_settings import INTERNAL_IPS
BASE_DIR = os.path.dirname(os.path.dirname(__file__))



# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'x395&0%#7ib51$p3b*5u#f@!$n&1481_m0g8fy4^2l!lkk4zb9'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'suit',
#     'bootstrap_admin', #一定要放在`django.contrib.admin`前面
    'django.contrib.admin', #默认添加后台管理功能
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'article',#this is the app name
    'django_markdown',
#     'debug_toolbar',
    'DjangoUeditor',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
#     'debug_toolbar.middleware.DebugToolbarMiddleware',#添加debug_toolbar
)

ROOT_URLCONF = 'blog_2.urls'
#suit配置
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP

TEMPLATE_CONTEXT_PROCESSORS = TCP + (
    'django.core.context_processors.request',
)
WSGI_APPLICATION = 'blog_2.wsgi.application'
INTERNAL_IPS = ('127.0.0.1',)

# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
#使用blog_2 数据库
if 'SERVER_SOFTWARE' not in os.environ:
    mysql_name = 'blogdb'
    mysql_user = 'root'
    mysql_pass = 'zhangyi'
    mysql_host = '127.0.0.1'
    mysql_host_s = ''
    mysql_port = '3306'
    DEBUG = True
else:
    mysql_name = sae.const.MYSQL_DB
    mysql_user  = sae.const.MYSQL_USER
    mysql_pass = sae.const.MYSQL_PASS
    mysql_host = sae.const.MYSQL_HOST
    mysql_host_s = sae.const.MYSQL_HOST_S
    mysql_port = sae.const.MYSQL_PORT
    DEBUG = True
TEMPLATE_DEBUG = DEBUG

ALLOWED_HOSTS = [
                 '.sinaapp.com',
                 ]
ADMINS = ()
MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': mysql_name,                   # Or path to database file if using sqlite3.
        'USER': mysql_user,                     # Not used with sqlite3.
        'PASSWORD': mysql_pass,                # Not used with sqlite3.
        'HOST': mysql_host,                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': mysql_port,                      # Set to empty string for default. Not used with sqlite3.
    },

    'slave': {
        'ENGINE': 'django.db.backends.mysql',   # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': mysql_name,                      # Or path to database file if using sqlite3.
        'USER': mysql_user,                      # Not used with sqlite3.
        'PASSWORD': mysql_pass,                  # Not used with sqlite3.
        'HOST': mysql_host_s,                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': mysql_port,                      # Set to empty string for default. Not used with sqlite3.
    }
}



# 七牛云存储
QINIU_ACCESS_KEY = '_pjeb98KcFbnyf-guKOJ-s42VMo3ebl01fRxfLid'
QINIU_SECRET_KEY = 'Dky76j8ewe0X0ic8LSipyZqjIB1aO4Ly3Z4pOxvX'
QINIU_BUCKET_NAME = 'happycode'
QINIU_DOMAIN = 'happyplay.qiniudn.com' 
# if 'SERVER_SOFTWARE' not in os.environ:
#     MEDIA_URL = '/image/'
#     FILE_UPLOAD_MAX_MEMORY_SIZE = 1204000 
#     DEFAULT_FILE_STORAGE = 'sae.ext.django.storage.backend.Storage'
#     STORAGE_BUCKET_NAME = 'image' 
# else:
#     MEDIA_URL = '/image/'
#     FILE_UPLOAD_MAX_MEMORY_SIZE = 1204000
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'zh-cn'

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = True
TEMPLATE_DIRS = (
    os.path.join(BASE_DIR,'templates')
    ),
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
# Additional locations of static files
# STATICFILES_DIRS = (
#     os.path.join(BASE_DIR,'static'),
#     # Put strings here, like "/home/html/static" or "C:/www/django/static".
#     # Always use forward slashes, even on Windows.
#     # Don't forget to use absolute paths, not relative paths.
# )
# Django-suit后台配置公共参数
SUIT_CONFIG = {
    # header
    'ADMIN_NAME': 'pythonblog',
}
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

